<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style> 
html,body {margin:0; padding:0;} 
div {text-align:center;} 
#wrapper {width:800px; overflow:hidden; margin:0 auto;} 
#wrapper #header {background-color:#ffff00; color:#bbb; height:100px;} 
#wrapper #menu {background-color:#bbb; height:50px; color:#fff; width:800px;} 
#wrapper #contents {background-color:#eee; height:1000px;} 
</style> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript"> 
$(function(){    
 var menupos = 
 $("#menu_bar").offset().top;    
 $(window).scroll(function(){       
 if($(window).scrollTop() >= menupos) {          
 $("#menu_bar").css("position","fixed");          
 $("#menu_bar").css("top","0");          
 } else {          
 $("#menu_bar").css("position","relative");          
 $("#menu_bar").css("top","");       
 }    
 }); 
 }); 
</script> 
</head> 
<body> 
<div id="wrapper"> 
<div id="header">header</div> 
<div id="menu_bar">menu</div> 
<div id="contents"> contents </div> 
</div> 
[출처] 스크롤후 메뉴바 고정|작성자 곰곰


</html>